<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>01收集表单数据</title>
  <script src="../js/vue.js"></script>
</head>
<body>
  <div id="app">
    <h1>{{title}}</h1>
    <!-- 
      v-model收集表单数据常用的修饰符
        trim
        number
        lazy
     -->
    <form>
      <label for="act">账号：</label>
      <input type="text" name="account" id="act" v-model.trim="account">
      <br>
      <label for="pwd">密码：</label>
      <input type="text" name="pasword" id="pwd" v-model="password">
      <br>
      <label for="age">年龄</label>
      <input type="number" name="age" id="age" v-model.number="age">
      <br>
      <label for="man">男</label>
      <input type="radio" name="gender" value="man" id="man" v-model="gender">
      <label for="woman">女</label>
      <input type="radio" name="gender" value="woman" id="woman" v-model="gender">
      <br>
      爱好：
      <label for="cy">抽烟</label>
      <input type="checkbox" name="hobby" id="cy" value="cy" v-model="hobby">
      <label for="hj">喝酒</label>
      <input type="checkbox" name="hobby" id="hj" value="hj" v-model="hobby">
      <label for="tt">烫头</label>
      <input type="checkbox" name="hobby" id="tt" value="tt" v-model="hobby">
      <br>
      <label for="xq">所属校区：</label>
      <select name="xq" id="xq" v-model="city">
        <option value="">选择校区</option>
        <option value="bj">北京</option>
        <option value="sh">上海</option>
        <option value="sz">深圳</option>
      </select>
      <br>
      <label for="other">其他信息：</label>
      <textarea name="other" id="other" v-model.lazy="other" cols="30" rows="10"></textarea>
      <br>
      <input type="checkbox" name="agree" v-model="agree">阅读并接受<a href="#">《用户协议》</a>
      <br>
      <button @click.prevent="handleSubmit">提交</button>
    </form>
  </div>
  <script>
    new Vue({
      el: '#app',
      data() {
        return {
          title: '收集表单数据',
          account: '',
          password: '',
          age: '',
          gender: '',
          hobby: [],
          city: '',
          other: '',
          agree: ''
        }
      },
      methods: {
        handleSubmit() {
          console.log(this._data)
        }
      }
    })
  </script>
</body>
</html>